<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>垂直水平居中</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .one {
            position: relative;
            margin: 10px;
            width: 200px;
            height: 200px;
            background-color: red;
        }
        .two {
            width: 100px;
            height: 100px;
            background-color: yellow;
            position: absolute; 
            left: 0; top: 0; right: 0; bottom: 0;
            margin: auto;
        }
    </style>
</head>
<body>
    <div class="one">
        <div class="two"></div>
    </div>
</body>
</html>